package com.itheima.article.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.article.pojo.ApAuthor;
import com.itheima.article.service.ApAuthorService;
import com.itheima.common.pojo.Result;
import com.itheima.core.controller.AbstractCoreController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* <p>
* APP文章作者信息表 控制器</p>
* @author 作者
* @since 2021-08-20
*/
@RestController
@RequestMapping("/apAuthor")
public class ApAuthorController extends AbstractCoreController<ApAuthor> {

    private ApAuthorService apAuthorService;

    //注入
    @Autowired
    public ApAuthorController(ApAuthorService apAuthorService) {
        super(apAuthorService);
        this.apAuthorService=apAuthorService;
    }


    /***
     * 根据userid获取作者信息
     */
    @GetMapping(value = "/user/{userid}")
    public Result<ApAuthor> getByUserId(@PathVariable(value = "userid")Integer id){
        QueryWrapper<ApAuthor> queryWrapper = new QueryWrapper<ApAuthor>();
        queryWrapper.eq("user_id",id);
        ApAuthor apAuthor = apAuthorService.getOne(queryWrapper);
        return Result.ok(apAuthor);
    }

}

